/**
 * @author Andoni Serrano
 */
package packLigaDeFutbol;

import java.sql.ResultSet;
import java.sql.SQLException;

public class HistoricoTemporada {
	
	static HistoricoTemporada miGestor;
	
	private HistoricoTemporada(){}
	
	public static HistoricoTemporada get(){
		
		if (miGestor == null){
			miGestor = new HistoricoTemporada();
		}
		
		return miGestor;
	}
	
	public ResultSet obtenerFechasDeTodasTemporadas(){
		
		String strSQL;
		ResultSet rs = null;
		
		strSQL = "SELECT DATE_FORMAT(fechainicio, '%Y') AS nombre, idtemporada AS valor" +
				" FROM temporada" +
				" ORDER BY fechaInicio;";
		try {
			
			rs = Principal.BBDD.consulta(strSQL);
			
			
		} catch (SQLException ex) {
			System.out.println("SQLException: " + ex.getMessage());
			System.out.println("SQLState: " + ex.getSQLState());
			System.out.println("VendorError: " + ex.getErrorCode());
		}
		
		
		return rs;
	}
	
	public ResultSet obtenerJornadasDeTemporada(int idTemporada){
		
		String strSQL;
		ResultSet rs = null;
		
		strSQL = "SELECT idjornada as valor, CONCAT(numjornada, ' (', DATE_FORMAT(fecha, '%d-%m-%Y'), ')') as nombre FROM jornada" +
				" WHERE idtemporada=" + idTemporada;
		try {
			
			rs = Principal.BBDD.consulta(strSQL);
			
			
		} catch (SQLException ex) {
			System.out.println("SQLException: " + ex.getMessage());
			System.out.println("SQLState: " + ex.getSQLState());
			System.out.println("VendorError: " + ex.getErrorCode());
		}
		
		
		return rs;
		
	}
}
